package com.hippo.core.tuya

import com.alibaba.fastjson.JSONObject

object DpHandler {



    /**
     * key ：code
     * value:dpId
     */
    val dpInfoMap = mutableMapOf<String, String>()

    fun getDpId(code:String):String{
        return dpInfoMap[code] ?: ""
    }


    fun wrapDps(dpId: String, dpValue:Any):String{
        val jsonObject = JSONObject()
        jsonObject[dpId] = dpValue
        return jsonObject.toString()
    }

    fun parseDps(dps:String):Map<String,Any>{
        val jsonObject = JSONObject.parseObject(dps)
        val map = mutableMapOf<String,Any>()
        jsonObject.forEach {
            map[it.key] = it.value
        }
        return map
    }

}